﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;
using System.Data;

namespace WebSite.cn
{
    public partial class topic : System.Web.UI.Page
    {
        // Fields
        public string content = "";

        // Methods
        private void Bind()
        {
            this.productsList.PageSize = Convert.ToInt32(info.info1("", "homeshowpnum5"));
            DataTable table = SQLAccess.GreatDs("select content from DB_topic where topicid=" + re.replace(base.Request.QueryString["tid"]) + "").Tables[0];
            if (table.Rows.Count > 0)
            {
                this.content = table.Rows[0][0].ToString();
            }
        }

        public void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if ((base.Request.QueryString["tid"] != null) && ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)))
            {
                Label label = (Label)e.Item.FindControl("price");
                Image image = (Image)e.Item.FindControl("Image1");
                if (image.ImageUrl.ToString() == "")
                {
                    image.ImageUrl = "../uploadfile/banner/" + info.info1("", "shopmopic");
                }
                else
                {
                    image.ImageUrl = "../uploadfile/product/" + image.ImageUrl.ToString();
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack && (base.Request.QueryString["tid"] != null))
            {
                this.Bind();
            }
        }

        protected void PageChanged(object sender, DataGridPageChangedEventArgs e)
        {
            this.productsList.CurrentPageIndex = e.NewPageIndex;
            string sql = "SELECT DB_Shoppro.*,DB_Topicpro.topicid FROM DB_Shoppro,DB_Topicpro,DB_Topic where DB_Shoppro.proid=DB_Topicpro.proid and DB_Topicpro.topicid=DB_Topic.topicid  and DB_Topicpro.topicid=" + re.replace(base.Request.QueryString["tid"]) + " and DB_Shoppro.visible=1 and DB_Shoppro.proisshow=1 and DB_Shoppro.languages=1 order by DB_Shoppro.proorder";
            DataTable table = new DataTable();
            table = SQLAccess.GreatDs(sql).Tables[0];
            this.productsList.DataSource = table.DefaultView;
            this.productsList.DataBind();
        }


    }
}